package cn.wolfcode.wolf2w.util;

import lombok.Getter;
import sun.rmi.runtime.Log;

@Getter
public enum RedisKeysStandard {
    TODAY_VIEW("today_view", -1L),
    //游记点赞的key实例
    TRAVEL_THUMB("travel_thumb",-1L),
    //攻略点赞的key实例
    STRATEGY_THUMB("strategy_thumb",-1L),
    //记录收藏状态的key实例
    USER_FAVOR_STRATEGIES("user_favor_strategies",-1L),
    //统计的vo对象key设计
    STATISTICS_VO_OBJECT("statistics_vo_object",-1L),
    // 手机验证码的key设计规范
    VERIFY_CODE("verify_code",Consts.VERIFY_CODE_VAI_TIME * 60L),
    // 用户Token令牌的key设计
    USER_TOKEN("user_token",Consts.USER_INFO_TOKEN_VAI_TIME * 60L),
    // 用户发送验证码的频率次数限制key设计
    VERIFY_CODE_FREQ("verify_code_freq",Consts.VERIFY_CODE_VAI_TIME * 60L);
    private String prefix; //key的前缀
    private Long time;// redis数据的存活时间

    private RedisKeysStandard(String prefix, Long time){
        this.prefix = prefix;
        this.time = time;
    }

    /**
     * 手动添加key的额外信息
     * @param message
     * @return
     */
    public String addKeyMessage(String ... message){
        StringBuilder sb = new StringBuilder();
        sb.append(this.prefix);
        for (String msg : message) {
            sb.append(":").append(msg);
        }
        return sb.toString();
    }
}
